
#include <iostream>
#include "CAS.hpp"

using namespace CAS;
using namespace std;
int main() {
    // 初始化表达式和规则
    Number initialExpr =  make_shared<BinaryExpr>(BinaryExpr::Op::Mul, make_shared<BinaryExpr>(BinaryExpr::Op::Add, Integer(1), Integer(2)), Variable("x"));
    RuleManager ruleManager;
    ruleManager.addRule(std::make_shared<AddZeroRule>());
    ruleManager.addRule(std::make_shared<CommutativeRule>());
    ruleManager.addRule(std::make_shared<MulZeroRule>());
    ruleManager.addRule(std::make_shared<AddIntRule>());
    ruleManager.addRule(std::make_shared<DistributionRule>());

    // 定义启发式函数
    auto heuristic = [](const CAS::Number& expr) {
        return to_string(expr).length();
    };

    // 执行 A* 算法
    CAS::Number simplifiedExpr = RuleEngine::aStarSimplify(move(initialExpr), ruleManager, heuristic);

    // 输出结果
    cout << "Simplified Expression: " << to_string(simplifiedExpr) << endl;

    return 0;
}